package kuangshen.daemon;

/**
 * @program: liangt
 * @description: 测试守护线程
 * @author: liangt
 * @create: 2021-03-03 14:10
 */
public class TestDaemon {

    public static void main(String[] args) {
        God god =new God();
        You you = new You();

        Thread thread = new Thread(god);
        thread.setDaemon(true);// 将线程设置为守护线程

        thread.start();
        new Thread(you).start();

    }
}
class God implements Runnable{

    @Override
    public void run() {
        while (true){
            System.out.println("上帝守护你！");
        }
    }
}

class You implements Runnable{
    @Override
    public void run() {
        for (int i = 0; i < 36500; i++) {
            System.out.println("开心每一条");
        }
        System.out.println("线程结束");
    }
}
